package com.dbms.utils;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

public class JsonUtil {

    public static JSONObject findMaxMqObject(JSONArray jsonArray) {
        JSONObject maxObject = null;
        double maxMq = Double.MIN_VALUE;
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject obj = jsonArray.getJSONObject(i);
            double mqValue;
            try {
                mqValue = Double.parseDouble(obj.getString("mq"));
            } catch (NumberFormatException e) {
                continue;
            }
            if (mqValue > maxMq) {
                maxMq = mqValue;
                maxObject = obj;
            }
        }
        return maxObject;
    }
}
